package swap;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-06-29
 * Time: 10:24
 */
//java中无法获取到栈上的地址，将要交换的数据存放在堆上
public class Test {
    public static void swap(int[] arr){
        int tmp = arr[0];
        arr[0] = arr[1];
        arr[1] = tmp;
    }
    public static void main(String[] args) {
        int[] arr = {10,20};
        System.out.println("交换前"+Arrays.toString(arr));
       swap(arr);
        System.out.println("交换后"+Arrays.toString(arr));
    }

}
